02. Organizing API endpoints

Organizing API endpoints

Organizing API Endpoints

FSND C2 L3 A02 Organizing API Endpoints

When organizing API endpoints, they should be based on the resources instead of on actions. The request methods will determine what action should be taken at a given URL endpoint. Your entire API's scheme should be consistent, clear and concise. Below are the principles and examples from the video, for your reference:

Principles

Methods & Endpoints Review

The request method used will determine the operation performed for the given resource URI. Though your API documentation should explain exactly what operation is performed and data returned via the response, it should be intuitive for anyone using your API, such as in the example below.

FSND C2 L3 A03 Methods And Endpoints Review

Organizing API endpoints Quiz

Which endpoint is correctly formatted to complete operations on all movies of genre id 1 ?

SOLUTION: genres/1/movies

Organizing API endpoints Quiz 2

Which method—endpoint combination should you use to create a new movie of genre 1 ?

SOLUTION: POST genres/1/movies

QUIZ QUESTION: :

The following API endpoints are poorly formatted. Match each endpoint with the principle of API endpoints that it violates.

ANSWER CHOICES:



Endpoint

Principle

Use nouns in the path, not verbs

Use parameters to specify a specific item

Plural nouns for collections

Endpoints should not be lengthy or complex

SOLUTION:

Endpoint

Principle

Use nouns in the path, not verbs

Use parameters to specify a specific item

Plural nouns for collections

Endpoints should not be lengthy or complex

Which of the following endpoint-method combinations would raise an error?

SOLUTION: POST /messages/1

Which of the following endpoint-method combinations would you use to make a partial update to all reactions to message 47?

SOLUTION: PATCH /messages/47/reactions

Which of the following endpoint-method combinations would you use to make a new reaction to message 47?

SOLUTION: POST /messages/47/reactions

Which of the following endpoint-method combinations updates the entirety of the representations of the reactions to message 47?

SOLUTION: PUT /messages/47/reactions